/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.unibo.as.heartsprojectdb;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lilith
 */
@Entity
@Table(name = "gameplayer")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Gameplayer.findAll", query = "SELECT g FROM Gameplayer g"),
    @NamedQuery(name = "Gameplayer.findById", query = "SELECT g FROM Gameplayer g WHERE g.id = :id"),
    @NamedQuery(name = "Gameplayer.findByPlayerPoint", query = "SELECT g FROM Gameplayer g WHERE g.playerPoint = :playerPoint")})
public class Gameplayer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Column(name = "playerPoint")
    private Integer playerPoint;
    @JoinColumn(name = "gameID", referencedColumnName = "typeID")
    @ManyToOne(optional = false)
    private Gametype gameID;
    @JoinColumn(name = "userEmail", referencedColumnName = "userEmail")
    @ManyToOne(optional = false)
    private Gameusers userEmail;

    public Gameplayer() {
    }

    public Gameplayer(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getPlayerPoint() {
        return playerPoint;
    }

    public void setPlayerPoint(Integer playerPoint) {
        this.playerPoint = playerPoint;
    }

    public Gametype getGameID() {
        return gameID;
    }

    public void setGameID(Gametype gameID) {
        this.gameID = gameID;
    }

    public Gameusers getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(Gameusers userEmail) {
        this.userEmail = userEmail;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Gameplayer)) {
            return false;
        }
        Gameplayer other = (Gameplayer) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.unibo.as.heartsprojectdb.Gameplayer[ id=" + id + " ]";
    }
    
}
